package com.smh.a16exerciseDemo3;

public class MyThread extends Thread {
    static int i = 1;

    @Override
    public void run() {
        while (true) {
            synchronized (MyThread.class) {
                if (i == 100) {
                    break;
                } else {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    if ((i % 2) == 1) {
                        System.out.println(Thread.currentThread().getName() + "@" + i);
                    }
                    i++;
                }
            }
        }
    }
}
